package cn.dengta.webapp.trade.entity.meta;

import cn.dengta.webapp.trade.entity.meta.MetaConfig.MetaRuleConfig;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.Assert;

/**
 * 互关免费聊天的规则配置对象
 */
@Getter
@Setter
public class ImFreeChatRule implements MetaRuleConfig {

	/** 气泡引导最小值 */
	private Integer bubbleMin;
	/** 免费聊天限制 */
	private Integer freeChatLimit;

	@Override
	public void validate() {
		Assert.isTrue(bubbleMin >= 0, "气泡引导最小值必须 >= 0！");
		Assert.isTrue(bubbleMin <= 5, "气泡引导最小值必须 <= 5！");
		Assert.isTrue(freeChatLimit > 0, "免费聊天的亲密度必须 > 0！");
		Assert.isTrue(freeChatLimit <= 5, "免费聊天的亲密度必须 <= 5！");
		Assert.isTrue(freeChatLimit >= bubbleMin, "免费聊天设置必须大于气泡引导最大值！");
	}

	@Override
	public void init(MetaRuleConfig config) {
		ImFreeChatRule rule = (ImFreeChatRule) config;
		this.bubbleMin = rule.bubbleMin;
		this.freeChatLimit = rule.freeChatLimit;
	}

}
